package com.laoda.ikun_food.controller.admin;

import com.laoda.ikun_food.entity.Diningroom;
import com.laoda.ikun_food.service.DiningroomService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/admin")
@AllArgsConstructor
public class AdminHomeController {

    private final DiningroomService diningroomService;
    @GetMapping("/adminhome")
    public String AdminHome(Model model,
            @RequestParam(name = "id",required = false,defaultValue = "1") String id)
        {
           Diningroom diningroom = diningroomService.getById(id);
           model.addAttribute("diningroom",diningroom);
            return "admin/adminhome";
        }
}
